package com.mobileares.midp.widgets.client.panel;

import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.event.dom.client.HasContextMenuHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.SimplePanel;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-11-15
 * Time: 11:25:54
 * To change this template use File | Settings | File Templates.
 */
public class ContextMenuPanel extends SimplePanel implements HasContextMenuHandlers {

    public ContextMenuPanel() {
    }

    public HandlerRegistration addContextMenuHandler(ContextMenuHandler handler) {
        return addDomHandler(handler, ContextMenuEvent.getType());
    }

    @Override
    public void onBrowserEvent(Event event) {
        switch (DOM.eventGetType(event)) {
            case Event.ONCONTEXTMENU:
                event.preventDefault();

                event.stopPropagation();
        }
        super.onBrowserEvent(event);
    }
}
